<%--
  Created by IntelliJ IDEA.
  User: maliangcheng
  Date: 2020/8/16
  Time: 13:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="head.jsp"%>
<html>
<head>
    <title>orderDetails</title>
    <link rel="stylesheet" href="/resource/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.js"></script>
</head>
<body>
<div style=" background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-icon-align,layui-card-header" style="height: 50px;margin-top: 20px">
                    <i class="layui-icon layui-icon-form" style="font-size:30px;margin-left: 30px;margin-inside: 20px"></i>
                    订单明细</div>
            </div>
        </div>
    </div>
</div>
<table class="layui-table" lay-data="{align:'center',height:330, url:'',id:'idTest'}" >
    <thead>
    <tr>
        <th lay-data="{field:'ID', sort: true, fixed: true}">订单明细编号</th>
        <th lay-data="{field:'goodsId'}">商品编号</th>
        <th lay-data="{field:'orderId', sort: true}">订单编号</th>
        <th lay-data="{field:'note'}">备注</th>
        <th lay-data="{field:'number'}">数量</th>
        <th lay-data="{field:'unitPrice', sort: true}">单价</th>
        <th lay-data="{field:'totalPrice', sort: true}">合计</th>
    </tr>
    </thead>
    <tbody>
        <tr>
            <td>${orderDetails.ID}</td>
            <td>${orderDetails.goodsId}</td>
            <td>${orderDetails.orderId}</td>
            <td>${orderDetails.note}</td>
            <td>${orderDetails.number}</td>
            <td>${orderDetails.unitPrice}</td>
            <td>${orderDetails.totalPrice}</td>
        </tr>
    </tbody>
</table>
<script src="/resource/layui/layui.js" charset="utf-8"></script>
<script src="../js/orderDetails.js"></script>
<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });

        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
</body>
</html>
